<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>参数的默认值</title>
</head>

<body>
  <script>
    // 具有默认值的参数，一般位置要靠后(潜规则，放前面也行)
    //   function add(a, b, c = 11) {
    //     return a + b + c;
    //   }
    //   console.log(add(1, 2)); //14
    //   console.log(add(1, 2, 9)); //12

    function connect({host='127.0.0.1',username,password='654321',port}) {
      console.log(host);//127.0.0.1
      console.log(username);//root
      console.log(password);//123456
      console.log(port);//3306
    }
    connect({
      username: 'root',
      password: '123456',
      port: 3306
    }) 
  </script>
</body>

</html>